<?php
header('Content-Type:text/html; charset=UTF-8');
$pdo = new PDO('mysql:dbname=dcxt;charset=utf8', 'root');
@$account = $_POST['account'];
@$password = $_POST['password'];
?>
<html>
<head>
<title>Bootstrap 模板</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
	charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="web/css/bootstrap.min.css" rel="stylesheet">
<script src="web/js/jquery-1.11.1.min.js"></script>
<script src="web/js/bootstrap.min.js"></script>
<!--[if lt IE 9]>
		<script src="js/html5shiv.js"></script>
		<script src="js/respond.min.js"></script>
		<![endif]-->
</head>
<body>
	<br />
	<br />
	<div class="container">
		<div class="row">
			<div class="col-xs-4 col-xs-offset-4">
				<?php
    $s = $pdo->prepare('select * from username');
    $s->execute();
    $data = $s->fetchAll(PDO::FETCH_NAMED);
    if ($account != null && $password != null) {
        foreach ($data as $value) {
            if ($account == $value['name']) {
                break;
            }
        }
        if ($account != $value['name']) {
            ?>
				<div class="alert alert-danger alert-dismissible ">
					<button type="button" class="close" data-dismiss="alert">
						<span>&times;</span>
					</button>
					用户不存在
				</div>
            <?php
        } elseif ($password == $value['password']) {
            session_start();
            $_SESSION['user'] = $account;
            header('Location:dcxt.php');
        } else {
            ?>
				<div class="alert alert-danger alert-dismissible ">
					<button type="button" class="close" data-dismiss="alert">
						<span>&times;</span>
					</button>
					密码错误
				</div>
        <?php
        }
    }
    ?>
					<div class="panel panel-primary">
					<div class="panel-heading">
						<div class="panel-lilte">
							<span class=" glyphicon glyphicon-glass">
								<b>登录点餐系统</b>
							</span>
						</div>
					</div>
					<div class="panel-body">
						<form class="form-horizontal" method="post" action="#">
							<div class="form-group">
								<label for="aa" class="control-label col-xs-4">登录名:</label>
								<div class="col-xs-8">
									<input id="aa" class="form-control" required="required"
										placeholder="登录名" name="account" />
								</div>
							</div>
							<div class="form-group">
								<label for="bb" class="control-label col-xs-4">密&nbsp;&nbsp;&nbsp;码:</label>
								<div class="col-xs-8">
									<input id="bb" class="form-control" type="password"
										required="required" placeholder="密码" name="password" />
								</div>
							</div>
							<div class="form-group">
								<button class="btn btn-primary col-xs-3  col-xs-offset-7"
									type="submit">登录</button>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>